inclinometer4 2.2.0
Loading...
Searching...
No Matches
inclinometer4


Inclinometer 4 Click

Inclinometer 4 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Jun 2024.
  • Type : I2C/SPI type

Software Support

Example Description

This example demonstrates the use of Inclinometer 4 Click board by reading and displaying accel data (X, Y, and Z axis) as well as temperature measurements on the USB UART.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Inclinometer4

Example Key Functions

Application Init

Initializes the driver and performs the Click default configuration which enables data ready interrupt on INT2 pin and sets full scale range to +/-2G and output data rate to 160ms.

void application_init ( void )
{
log_cfg_t log_cfg;
inclinometer4_cfg_t inclinometer4_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
inclinometer4_cfg_setup( &inclinometer4_cfg );
INCLINOMETER4_MAP_MIKROBUS( inclinometer4_cfg, MIKROBUS_1 );
err_t init_flag = inclinometer4_init( &inclinometer4, &inclinometer4_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( INCLINOMETER4_ERROR == inclinometer4_default_cfg ( &inclinometer4 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define INCLINOMETER4_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition inclinometer4.h:315
@ INCLINOMETER4_ERROR
Definition inclinometer4.h:415
void application_init(void)
Definition main.c:30

Application Task

Waits for a data ready interrupt, then reads and displays the accel data (X, Y, and Z axis) as well as temperature measurements on the USB UART.

void application_task ( void )
{
// Wait for a data ready interrupt
while ( inclinometer4_get_int2_pin ( &inclinometer4 ) );
if ( INCLINOMETER4_OK == inclinometer4_get_data ( &inclinometer4, &accel_data ) )
{
log_printf( &logger, " X: %.3f g\r\n", accel_data.x );
log_printf( &logger, " Y: %.3f g\r\n", accel_data.y );
log_printf( &logger, " Z: %.3f g\r\n", accel_data.z );
log_printf( &logger, " Temperature: %d degC\r\n\n", ( int16_t ) accel_data.temperature );
}
}
@ INCLINOMETER4_OK
Definition inclinometer4.h:414
void application_task(void)
Definition main.c:67
int8_t temperature
Definition inclinometer4.h:404
float y
Definition inclinometer4.h:402
float x
Definition inclinometer4.h:401
float z
Definition inclinometer4.h:403

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.